<?php
class My_Message {

    function  __construct($name) {
        $this->name = 'messages_'.$name;
        
        if (!Zend_Registry::isRegistered($this->name)) {
           $this->_create();
        }
    }

    function _create()
    {
        Zend_Registry::set($this->name, array());
    }

    function add($msg)
    {
        $messages = Zend_Registry::get($this->name);
        array_push($messages, $msg);
        Zend_Registry::set($this->name, $messages);
    }

    function get()
    {
        $messages = Zend_Registry::get($this->name);
        $return = array_pop($messages);
        Zend_Registry::set($this->name, $messages);
        return $return;
    }

    function getCount()
    {
        return count(Zend_Registry::get($this->name));
    }

    function _unset()
    {
        Zend_Registry::set($this->name, null);
    }

}
?>
